﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Soufun.DB;
using System.Data;

namespace Soufun.DAL
{
    public class DHouseType
    {
        public string GetHouseType(int projectId,double houseArea)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  HouseType  from tprojecthousetypeinfo ");
            strSql.Append("where ProjectId =");
            strSql.Append(projectId);
           // strSql.Append(" and UnitId = ");
            //strSql.Append(unitId);
            strSql.Append(" and HouseArea = ");
            strSql.Append(houseArea);
            DataSet ds = DbHelper.Query(strSql.ToString());
            if (ds==null || ds.Tables.Count==0||ds.Tables[0].Rows.Count==0)
            {
                return "";
            }
            return ds.Tables[0].Rows[0][0].ToString();
        }

        public DataSet GetProjectHouseTypeList(int projectId)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  HouseType,HouseArea from tprojecthousetypeinfo ");
            strSql.Append("where ProjectId =");
            strSql.Append(projectId);
            DataSet ds = DbHelper.Query(strSql.ToString());
            if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
            {
                return null;
            }
            return ds;
        }

        public int Delete(int projectId)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from tprojecthousetypeinfo ");
            strSql.Append("where ProjectId=");
            strSql.Append(projectId);
            int result = DbHelper.ExecuteSql(strSql.ToString());
            return result;
        }

        //public DataSet GetListByProjectId()
        //{
            
        //}
    }
}
